package com.ydche.dao.impl;

import com.ydche.dao.IUserDao;
import com.ydche.idl_output.UserProfile;
import org.springframework.stereotype.Service;
import com.ydche.client.SimpleClient;
import com.ydche.util.MyException;

@Service
public class UserDaoImpl implements IUserDao {
    @Override
    public int addUser(UserProfile user) {
        int userId = 0;
        try {
            userId = SimpleClient.getClient().add_user(user);
        } catch (Exception e) {
            MyException.handleThriftException(e);
        }
        return userId;
    }

    @Override
    public UserProfile getUserByMobile(String mobile) {
        UserProfile user = null;
        try {
            user = SimpleClient.getClient().get_user_by_mobile(mobile);
        } catch (Exception e) {
            MyException.handleThriftException(e);
        }
        return user;
    }

    @Override
    public int updateUser(UserProfile user) {
        int lines = 0;
        try {
            lines = SimpleClient.getClient().update_user(user);
        } catch (Exception e) {
            MyException.handleThriftException(e);
        }
        return lines;
    }
}
